package com.cy.java.basic;

import java.util.Arrays;

public class pxsf {
    public static void main(String[] args) {
        int arr []={6,52,19,7,28,32,84,24,88,18};
       pxsf arrr= new pxsf();
      int[] a= arrr.BubbleSort(arr);

        System.out.println(Arrays.toString(arr));

    }

    public int[] BubbleSort(int[] arr){
        for(int i=0;i<arr.length-1;i++){
            for(int j=0;j<arr.length-1-i;j++){
                if(arr[j]>arr[j+1]){ //相邻两个元素作比较，如果前面元素大于后面，进行交换
                    int temp = arr[j+1];
                    arr[j+1] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        return arr;
    }
}
